
package com.ukao.cashregister.pesenter;

import com.ukao.cashregister.base.BasePresenter;
import com.ukao.cashregister.bean.BalanceBean;
import com.ukao.cashregister.bean.StringBean;
import com.ukao.cashregister.consts.Constant;
import com.ukao.cashregister.consts.SaveParamets;
import com.ukao.cashregister.retrofit.ApiCallback;
import com.ukao.cashregister.utils.Utils;
import com.ukao.cashregister.view.MainSweepView;

import java.util.HashMap;

/**
 * Created by ukaodev on 2017/6/28.
 */

public class MainSweepPesenter extends BasePresenter<MainSweepView> {

    public MainSweepPesenter(MainSweepView view) {
        attachView(view);
    }



    public void wxMicroPay (String orderId,String  balance,String  paymentCode ) {
        mvpView.showLoading();
        HashMap     mHashMap=new HashMap<String,String>();
        mHashMap.put("orderId",orderId  );
        mHashMap.put("balance", String.valueOf((int) (Double.valueOf(balance)* 100)));
        mHashMap.put("authCode",paymentCode);
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.wxMicroPay (Constant.createParameter(mHashMap)),
                new ApiCallback<StringBean>() {
                    @Override
                    public void onSuccess(StringBean model) {
                        if (model.getHttpCode()==200){
                           mvpView.loadPayData(model.getMsg());
                        }else{
                            mvpView.loadFail(model.getMsg());
                        }

                    }



                    @Override
                    public void onFinish() {
                        mvpView.hideLoading();
                    }

                });
    }





    public void queryStatusBySeq (String seq  ) {
        HashMap mHashMap = new HashMap<String, String>();
        mHashMap.put("seq", seq);
        mHashMap.put("accessToken", SaveParamets.getToken(Utils.getContext()));
        addSubscription(apiStores.queryStatusBySeq(Constant.createParameter(mHashMap)),
                new ApiCallback<BalanceBean>() {
                    @Override
                    public void onSuccess(BalanceBean model) {
                        if (model.getHttpCode() == 200) {
                      //      mvpView.queryStatusData(model.getData());
                        } else {
                         //   mvpView.loadFail(model.getMsg());
                        }

                    }


                    @Override
                    public void onFinish() {
                    }

                });


    }

}
